package com.caoheng.pay.pay.handler;

import com.alibaba.fastjson.JSONObject;
import com.caoheng.core.common.body.PayRequestBody;
import com.caoheng.core.enums.PayType;
import com.caoheng.pay.pay.PayExecutor;
import org.springframework.util.Assert;

public abstract class BasePayExecutor implements PayExecutor {



    /**
     * 参数校验、验签处理
     * @param param 支付请求的参数,商户信息
     * @return
     */
    protected boolean validateRequestParam(PayRequestBody param){
        //todo
        return true;
    }

    /**
     * 执行支付处理
     * @param requestBody
     * @param <E>
     * @return
     */
    @Override
    public <E> E execute(JSONObject payRequestParam,PayRequestBody requestBody) {
        Assert.isTrue(validateRequestParam(requestBody),"验签失败!");
        return doExecute(payRequestParam,requestBody);
    }

    public abstract <E> E doExecute(JSONObject payRequestParam,PayRequestBody requestBody);
}
